package com.daviteq.user.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.daviteq.ems.dao.cassandra.IUserDAO;
import com.daviteq.ems.dao.cassandra.impl.UserDAO;
import com.daviteq.ems.entity.UserEntity;

public class UserService {

	private IUserDAO userDao = new UserDAO();
	
	public List<UserEntity> getAll() {
		return userDao.findAll(1000);
	}
	
	public boolean insertUser(UserEntity user) {
		return userDao.persist(user);
	}
	public boolean deleteUser(String id){
		return userDao.remove(id);
	}
	public UserEntity getUserById(String username) {
		return userDao.findById(username);
	}
	
	
	public boolean updateUser(UserEntity user) {
		Map<String, Object> cols = new HashMap<String, Object>();
		cols.put(UserEntity.FIRST_NAME, user.getFirstName());
		cols.put(UserEntity.LAST_NAME, user.getLastName());
		cols.put(UserEntity.GENDER, user.getGender());
		cols.put(UserEntity.EMAIL, user.getEmail());
		cols.put(UserEntity.MOBILE, user.getMobile());
		cols.put(UserEntity.BIRTHDAY, user.getBirthday());
		cols.put(UserEntity.STATUS, user.getStatus());
		return userDao.updateMultiColsById(cols, UserEntity.USERNAME, user.getUsername());
	}
	
	public static void main(String[] args) {
		//UserService userService = new UserService();
		//userService.getUserById("");
		//System.out.println(userService.getUserById("user_64"));
		System.out.println("int max:"+Integer.MAX_VALUE);
		System.out.println("float max:"+Float.MAX_VALUE);
	
		
//		
//		UserEntity user = new UserEntity();
//		user.setUsername("fds");
//		user.setPassword("asdsad");
//		userService.insert(user );
//		System.out.println(userService.getAll());
//		System.out.println(userService.getUserById("user_66"));
	}
}
